#ifndef WATCHERMAINWINDOW_H
#define WATCHERMAINWINDOW_H

#include <QMainWindow>

class MakefileWidget;
class QFileSystemWatcher;
class QProcess;
class QSplitter;

namespace Ui {
class WatcherMainWindow;
}

class WatcherMainWindow : public QMainWindow {
  Q_OBJECT

public:
  explicit WatcherMainWindow(QWidget *parent = nullptr);
  ~WatcherMainWindow();
  void add(QString path);

  void log(QString msg);
  void runCmd(QString dir, QString cmd);

private:
  void updateCount(QString path);

private:
  Ui::WatcherMainWindow *ui;
  QList<MakefileWidget *> m_mks;
  QString m_buildPath, m_sourcePath;
  QProcess *m_make, *m_listen;
  QSplitter *sp;
  QFileSystemWatcher *fsw;

  // QWidget interface
protected:
  virtual void showEvent(QShowEvent *event) override;

  // QWidget interface
protected:
  virtual void resizeEvent(QResizeEvent *event) override;
};

#endif // WATCHERMAINWINDOW_H
